import command.*;
import decorator.Coffee;
import decorator.MilkDecorator;
import decorator.SimpleCoffee;
import decorator.SugarDecorator;
import factory.Shape;
import factory.ShapeFactory;
import singleton.Singleton;

public class Main {
    public static void main(String[] args) {
        // 单例模式
        System.out.println("------单例模式------");
        Singleton singleton = Singleton.getInstance();
        singleton.showMessage();

        // 工厂模式
        System.out.println("------工厂模式------");
        ShapeFactory shapeFactory = new ShapeFactory();
        Shape circle = shapeFactory.getShape("圆形");
        circle.draw();
        Shape rectangle = shapeFactory.getShape("矩形");
        rectangle.draw();

        // 命令模式
        System.out.println("------命令模式------");
        Light light = new Light();
        Command turnOnCommand = new TurnOnLightCommand(light);
        Command turnOffCommand = new TurnOffLightCommand(light);
        RemoteControl remote = new RemoteControl();
        remote.setCommand(turnOnCommand);
        remote.pressButton();
        remote.setCommand(turnOffCommand);
        remote.pressButton();

        // 装饰者模式
        System.out.println("------装饰者模式------");
        Coffee simpleCoffee = new SimpleCoffee();
        System.out.println(simpleCoffee.getDescription() + " 价格: " + simpleCoffee.getCost());

        Coffee milkCoffee = new MilkDecorator(simpleCoffee);
        System.out.println(milkCoffee.getDescription() + " 价格: " + milkCoffee.getCost());

        Coffee sugarMilkCoffee = new SugarDecorator(milkCoffee);
        System.out.println(sugarMilkCoffee.getDescription() + " 价格: " + sugarMilkCoffee.getCost());
    }
}
